package com.yishun.springboot.web;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yinquan.util.ResultUtils;
import com.yishun.springboot.pojo.GwsVehicleDTO;
import com.yishun.springboot.service.GongWuSuTimedUploadVehicleHeartBeatService;

@RestController
@RequestMapping("cityVehicle")
public class GwsCityVehicleController {

	@Resource
	GongWuSuTimedUploadVehicleHeartBeatService beatService;

	@RequestMapping("/uploadVehicleDetailed")
	public String uploadVehicleDetailed(@RequestBody JSONObject jsonObject) {

		GwsVehicleDTO dto = JSONObject.toJavaObject(jsonObject, GwsVehicleDTO.class);

		String res = "";

		if (dto == null) {
			return JSONObject.toJSONString(ResultUtils.jsonFail(400), SerializerFeature.WriteMapNullValue);
		}

		try {
			res = beatService.uploadVehicleDetailed(dto);
		} catch (Exception e) {
			e.printStackTrace();
			return JSONObject.toJSONString(ResultUtils.jsonFail("程序异常，请联系管理员"), SerializerFeature.WriteMapNullValue);
		}

		return res;
	}

}
